package com.example.imagehost.controller;

import com.example.imagehost.bean.Image;
import com.example.imagehost.bean.ServerProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class HelloController {
    ApplicationContext context = new ClassPathXmlApplicationContext("ImageConfig.xml");

    @Autowired
    private ServerProperties serverProperties;

    @ResponseBody
    @RequestMapping("/Hello")
    public String Hello(){
        String attr = "";
        attr += "Author: 一番巨大悠\n";
        attr += serverProperties.toString();
        return attr;
    }


    //private Image image;
    private Image image = (Image) context.getBean("image");
    @ResponseBody
    @RequestMapping("/Image")
    public String Image(){
        return image.toString();
    }
}
